package com.nf.practice.excelConvert;

import com.alibaba.excel.EasyExcel;

import java.io.File;
import java.util.List;

public class ExcelToSql {

    public static void main(String[] args) {
        String excelFilePath = "E:/file/jdH5.xlsx";
        List<TblPsLog> tblPsLogs = readExcelAndGenerateSql(excelFilePath);
        for (TblPsLog tblPsLog : tblPsLogs) {
            System.out.println("INSERT INTO `tbl_calculate_cost_info_log` (`card_id`,`business_type`, `business_scenario`, `credit_source`, `update_time`, `create_time`) VALUES ('"
                    + tblPsLog.getCard_id() + "', 'offline', " + "'in_borrow', " + "'JDH5', '" + tblPsLog.getCreateTime() + "', '" + tblPsLog.getUpdateTime() + "');");
        }
    }

    public static List<TblPsLog> readExcelAndGenerateSql(String filePath) {
        File excelFile = new File(filePath);
        return EasyExcel.read(excelFile).head(TblPsLog.class).sheet().doReadSync();
    }
}
